home *** CD-ROM | disk | FTP | other *** search
/ Belgian Amiga Club - ADF Collection / BS1 part 21.zip / BS1 part 21 / Professional Page v4.0 (1993)(Gold Disk)(Disk 1 of 4)[HD].7z / Professional Page v4.0 (1993)(Gold Disk)(Disk 1 of 4)[HD].adf / rexx.lzh / GetTaggedText.pprx < prev    next >
Text File  |  1993-01-28  |  2KB  |  119 lines

  1. /*
  2. @BGetTaggedText  @P@ICopyright Gold Disk Inc., Jan, 1993
  3.  
  4. This Genie will copy all text with a given style tag into a previously created box. (Suitable for automatic table of contents generation.)
  5.  
  6. */
  7. address command
  8. call SafeEndEdit.rexx()
  9. call ppm_AutoUpdate(0)
  10. cr = '0a'x
  11.  
  12. stlist  = ppm_GetStyleTagList()
  13. if stlist = "0"'0a'x then exit_msg("No tags are defined in current document.")
  14.  
  15. stlist  = delstr(stlist, 1, pos('0a'x, stlist))
  16.  
  17. tags = ppm_SelectFromList("Select tags to collect..", 30, 5, 1, stlist)
  18.  
  19. if tags = '' then exit_msg()
  20.  
  21. output = ppm_ClickOnBox("Select Box in which to place tagged text..")
  22. if output = 0 then exit_msg()
  23.  
  24. counter = 0
  25. call ppm_ShowStatus("Working..")
  26.  
  27. do while tags ~= ''
  28.  
  29.     counter = counter + 1
  30.     parse var tags tagitem.counter '0a'x tags
  31.  
  32. end
  33.  
  34. listcounter = 1
  35. bcounter    = 1
  36.  
  37. box         = ppm_DocFirstBox()
  38.  
  39. call ppm_ShowStatus("Working..")
  40.  
  41. do while box ~= 0
  42.  
  43.     if upper(word(ppm_GetBoxInfo(box), 1)) ~= 'TEXT' then
  44.     do
  45.         box = ppm_DocNextBox(box)
  46.         iterate
  47.     end
  48.  
  49.     boxtext = ppm_GetBoxText(box, 1)
  50.     tagpos  = pos('\dS<', boxtext)
  51.  
  52.     do while tagpos ~= 0
  53.  
  54.         tagpos  = tagpos + 4
  55.         endtag  = pos('>', boxtext, tagpos)
  56.  
  57.         if endtag = 0 then leave
  58.  
  59.         tagtext = substr(boxtext, tagpos, endtag - tagpos)
  60.  
  61.         do i = 1 to counter
  62.  
  63.             if tagtext ~= tagitem.i then iterate
  64.  
  65.             endpos = pos('\ds', boxtext, endtag)
  66.  
  67.             if endpos = 0 then
  68.                  do
  69.                     endpos = pos('0a'x, boxtext, endtag + 1)
  70.  
  71.                     if endpos = 0 then
  72.                                         endpos = pos('\.', boxtext, endtag + 1)
  73.                  end
  74.  
  75.             tagtext = "\dS<"tagtext">"
  76.             taglist.listcounter = tagtext || substr(boxtext, endtag + 1, endpos - 1 - endtag) || "\ds"
  77.             taglist.listcounter.1 = ppm_BoxPage(box)
  78.  
  79.             listcounter = listcounter + 1
  80.  
  81.             tagpos = endpos + 3
  82.             leave
  83.  
  84.         end
  85.  
  86.         tagpos = pos('\dS<', boxtext, tagpos)
  87.  
  88.     end
  89.  
  90.     box = ppm_DocNextBox(box)
  91.  
  92. end
  93.  
  94. text = ''
  95.  
  96. do i = 1 to listcounter - 1
  97.  
  98.     text = text || taglist.i || '09'x || taglist.i.1 || cr
  99.  
  100. end
  101.  
  102. call SafeSetEdit.rexx(output)
  103. call ppm_InsertText(text)
  104. call SafeEndEdit.rexx()
  105.  
  106.  
  107. exit_msg("Done")
  108.  
  109. exit_msg: procedure expose
  110. do
  111.  
  112.     parse arg message
  113.  
  114.     if message ~= '' then call ppm_Inform(1,message,)
  115.  
  116.     call ppm_AutoUpdate(1)
  117.     exit
  118. end
  119.